<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of s3db_resize</title>
  <meta name="keywords" content="s3db_resize">
  <meta name="description" content="S3DB_RESIZE called by ResizeFcn when widnows changes size">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">code</a> &gt; s3db_resize.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for code&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>s3db_resize
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>S3DB_RESIZE called by ResizeFcn when widnows changes size</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function h=s3db_resize(h,act) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">S3DB_RESIZE called by ResizeFcn when widnows changes size
Syntax: h=s3db_resize(h,act)
Description: In order for the panels to keep their pixel sizes, they have
             to be moved without streching them. Since this is going to be
             a recurring problem better do it all in one place, this
             function.

Jonas ALmeida, January 2008</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function h=s3db_resize(h,act)</a>
0002 
0003 <span class="comment">%S3DB_RESIZE called by ResizeFcn when widnows changes size</span>
0004 <span class="comment">%Syntax: h=s3db_resize(h,act)</span>
0005 <span class="comment">%Description: In order for the panels to keep their pixel sizes, they have</span>
0006 <span class="comment">%             to be moved without streching them. Since this is going to be</span>
0007 <span class="comment">%             a recurring problem better do it all in one place, this</span>
0008 <span class="comment">%             function.</span>
0009 <span class="comment">%</span>
0010 <span class="comment">%Jonas ALmeida, January 2008</span>
0011 
0012 
0013 <span class="keyword">if</span> nargin==0
0014    h=gcf;
0015 <span class="keyword">end</span>
0016 <span class="comment">% is there an old reccord of size?</span>
0017 config=get(h,<span class="string">'UserData'</span>);
0018 <span class="keyword">if</span> isempty(config)
0019    set(h,<span class="string">'ResizeFcn'</span>,[<span class="string">'s3db_resize('</span>,num2str(h),<span class="string">');'</span>])
0020    config.Position=get(h,<span class="string">'Position'</span>);
0021    set(h,<span class="string">'UserData'</span>,config);
0022 <span class="keyword">else</span>
0023    hh=get(h,<span class="string">'Children'</span>); <span class="comment">%get all children in figure</span>
0024    hh=hh(strmatch(<span class="string">'uipanel'</span>,get(hh,<span class="string">'Type'</span>))); <span class="comment">%keep only the panel handels</span>
0025    config=get(h,<span class="string">'UserData'</span>);old_pos=config.Position;
0026    new_pos=get(h,<span class="string">'Position'</span>); <span class="comment">% New Position</span>
0027    <span class="keyword">for</span> i=1:length(hh)
0028        pos=get(hh(i),<span class="string">'Position'</span>);
0029        xy=[pos(1),pos(2)+pos(4)]; <span class="comment">%target moving the top left-hand corners</span>
0030        <span class="comment">%difference</span>
0031        dpos=[new_pos(3)/old_pos(3),new_pos(4)/old_pos(4)];
0032        <span class="comment">%correct pos</span>
0033        xy=round(xy.*dpos); <span class="comment">%new upper left corners</span>
0034        pos(1)=xy(1);
0035        pos(2)=xy(2)-pos(4);
0036        set(hh(i),<span class="string">'Position'</span>,pos)
0037    <span class="keyword">end</span>
0038    config.Position=get(h,<span class="string">'Position'</span>);
0039    set(h,<span class="string">'UserData'</span>,config);
0040 
0041 
0042 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Tue 17-Feb-2009 16:14:02 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>